
from django.contrib.admin.templatetags.admin_list import *

def xadmin_list_filter(cl, spec):    
    if hasattr(spec, "USE_OUTPUT_FUNC"):        
        return spec.output(cl)
    else:
        ctx =  {'title': spec.title(), 
                'choices' : list(spec.choices(cl))
                }
        t = get_template('xadmin/filter.html')
        return t.render(Context(ctx))


xadmin_list_filter = register.simple_tag(xadmin_list_filter)

def xsearch_form(cl, search_help_text):
    return {
        'search_help_text': search_help_text ,
        'cl': cl,
        'show_result_count': cl.result_count != cl.full_result_count,
        'search_var': SEARCH_VAR
    }
xsearch_form = register.inclusion_tag('xadmin/search_form.html')(xsearch_form)

date_hierarchy = register.inclusion_tag('admin/date_hierarchy.html')(date_hierarchy)
result_list = register.inclusion_tag("admin/change_list_results.html")(result_list)
pagination = register.inclusion_tag('admin/pagination.html')(pagination)

